/*
 * CheckerTab.java
 *
 * Created on 22 de Dezembro de 2008, 20:12
 */

package br.com.kibutx.bixochecker.gui;

import java.awt.Color;

import br.com.kibutx.bixochecker.config.ProcessorsConfigManager;
import br.com.kibutx.bixochecker.gui.config.InvalidConfigException;

/**
 * 
 * @author moa
 */
public class CheckerTab extends javax.swing.JPanel {

	private ProcessorsListModel pModel;

	/** Creates new form CheckerTab */
	public CheckerTab() {
		initComponents();

		initList();
	}

	private void initList() {
		this.pModel = new ProcessorsListModel(this.checkersList);
		this.checkersList.setCellRenderer(new ProcessorsCellRenderer());
		this.checkersList.setModel(this.pModel);
		this.checkersList.setSelectionBackground(new Color(100,100,150));
		this.checkersList.setSelectionForeground(new Color(230,230,200));
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed" desc="Generated
	// <editor-fold defaultstate="collapsed" desc="Generated
	// Code">//GEN-BEGIN:initComponents
	private void initComponents() {

		chkListScrollPane = new javax.swing.JScrollPane();
		checkersList = new javax.swing.JList();

		chkListScrollPane.setViewportView(checkersList);

		org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
				this);
		this.setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(
				org.jdesktop.layout.GroupLayout.LEADING).add(
				layout.createSequentialGroup().addContainerGap().add(
						chkListScrollPane,
						org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 283,
						org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
						.addContainerGap(
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								Short.MAX_VALUE)));
		layout.setVerticalGroup(layout.createParallelGroup(
				org.jdesktop.layout.GroupLayout.LEADING).add(
				org.jdesktop.layout.GroupLayout.TRAILING,
				layout.createSequentialGroup().addContainerGap().add(
						chkListScrollPane,
						org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 276,
						Short.MAX_VALUE).addContainerGap()));
	}// </editor-fold>//GEN-END:initComponents

	// Variables declaration - do not modify//GEN-BEGIN:variables
	private javax.swing.JList checkersList;
	private javax.swing.JScrollPane chkListScrollPane;

	// End of variables declaration//GEN-END:variables

	public void load(ProcessorsConfigManager config) {
		this.pModel.load(config);
	}

	public void save(ProcessorsConfigManager config)
			throws InvalidConfigException {
		this.pModel.save(config);
	}

}
